package com.study.springbootsecurity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

// 二维码状态变更事件类型
@Getter
@AllArgsConstructor
public enum QrCodeStatuesChangeEventType {

    QR_CODE_GENERATED_EVENT(0,"二维码生成事件"),
    QR_CODE_SCANNED_EVENT (1,"二维码扫码事件"),
    USER_CONFIRMED_EVENT (2,"二维码扫码后,用户确认授权事件"),
    USER_CANCELED_EVENT (3,"二维码扫码后,用户取消授权事件"),
    EXPIRED_EVENT (4,"过期事件");

    private final int code;
    private final String desc;
    /**
     * @param code 二维码事件类型编号
     * @return QrCodeStatus 二维码事件类型枚举类
     */
    public static QrCodeStatuesChangeEventType getQrCodeEventByCode(int code) {
        QrCodeStatuesChangeEventType[] ecs = QrCodeStatuesChangeEventType.values();
        for (QrCodeStatuesChangeEventType ec : ecs) {
            if (ec.getCode() == code) {
                return ec;
            }
        }
        return null;
    }

}
